/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.controller;

import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import com.koron.purpose.utils.BusinessCode;
import com.koron.report.service.api.DrillPlanAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.swan.bean.MessageBean;
import springfox.documentation.annotations.ApiIgnore;


@Api(tags = "dataAnalysis", description = "应急演练统计")
@RestController
@RequestMapping("/dataAnalysis")
public class DrillPlanAnalysisController {
    @Autowired
    private DrillPlanAnalysisService drillPlanAnalysisService;

    @ApiOperation("应急演练统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgCode", value = "组织编码", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "departmentCode", value = "部门code", required = true, dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/drillTypeAndNum.htm", method = RequestMethod.GET)
    public MessageBean<?> analysisDrillPlan(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                            @RequestParam String orgCode,
                                            @RequestParam String departmentCode) {
        if (null == user) {
            MessageBean<?> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return drillPlanAnalysisService.analysisDrillPlan(orgCode,departmentCode);
    }
}
